<?php
//处理删除入库任务
$no_palno = true;
$no_intask = true;
$no_barcodeitem = true;
try{
    if($_GET['palno'] != null){
        $no_palno = false;
        $palno = $_GET['palno'];
        $db_wms = new PDO("sqlsrv:Server=192.168.1.203\MSSQL2014;Database=ZXZH_WMS", "sa", "Zxzh88888888");
        $db_wms->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $from = $db_wms->query("select guid from View_log_in_del where PALNO = '$palno'");
        $guid_array = $from->fetchAll();
        if(count($guid_array) > 0){
            $no_intask = false;
            foreach ($guid_array as $value){
                $guid = $value['guid'];
                $sql = "sp_del_intask '0073','$palno','','','','$guid','','','','','@out1','@out2','@out3','@out4','@out5','@out6','@out7','@out8','@out9','@out10','@out11','@out12','@out13','@out14','@out15','@out16','@out17','@out18','@out19','@out20','@reason'";
                $from = $db_wms->exec($sql);
            }
        }
        $from = $db_wms->query("select guid from View_barcodeitem where palno = '$palno'");
        $guid_array = $from->fetchAll();
        if(count($guid_array) > 0){
            $no_barcodeitem = false;
            foreach ($guid_array as $value){
                $guid = $value['guid'];
                $sql = "sp_del_barcode '0073', '$guid','','','','','','','','','@out1','@out2','@out3','@out4','@out5','@out6','@out7','@out8','@out9','@out10','@out11','@out12','@out13','@out14','@out15','@out16','@out17','@out18','@out19','@out20','@reason'";
                $db_wms->exec($sql);
            }
        }
    }
}
catch(PDOException $e){
    die ("Error!: " . $e->getMessage() . "<br/>");
}
if($no_palno){
    echo "请填写托盘号！";
}
else{
    if(!$no_intask){
        echo "已删除入库任务！";
    }
    if(!$no_barcodeitem){
        echo "已删除物料查询内容！";
    }
    if($no_intask && $no_barcodeitem){
        echo "未查询到该条码！";
    }
}